package org.sg20.searchengine.invertedindex;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import org.sg20.parsename.ParseNameOutputKey;

import java.io.IOException;

public class InvertedIndexReducer extends Reducer<Text, ParseNameOutputKey, Text, Text> {
    // There is nothing to do for reducer
    @Override
    protected void reduce(Text key, Iterable<ParseNameOutputKey> values, Reducer<Text, ParseNameOutputKey, Text, Text>.Context context) throws IOException, InterruptedException {
        StringBuilder str = new StringBuilder();
        for (ParseNameOutputKey value : values) {
            str.append(value.toString());
            str.append("\t");
        }
        context.write(key, new Text(str.toString()));

    }
}
